package com.orchid.community.models.controller;

import cn.hutool.core.util.StrUtil;
import com.orchid.community.common.utils.MsgResponse;
import com.orchid.community.common.utils.ResultUtils;
import com.orchid.community.models.DTO.MissionDto;
import com.orchid.community.models.DTO.MissionPageParam;
import com.orchid.community.models.service.MissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Objects;

@Slf4j
@RestController
@RequestMapping("/mission")
public class MissionController {

    @Autowired
    private MissionService missionService;

    /**
     * 获取所有场景标签
     * @return
     */
    @PostMapping("/getSceneTags")
    public MsgResponse getSceneTags() {
        return missionService.getSceneTags();
    }

    @PostMapping("/addMission")
    public MsgResponse addMission(@RequestBody Map<String, Object> map) {
        return missionService.addMission(map);
    }

    @PostMapping("/getMissionPage")
    public MsgResponse getMissionPage(@RequestBody MissionPageParam missionPageParam) {
        return missionService.getMissionPage(missionPageParam);
    }

    @PostMapping("/getMissionInfo")
    public MsgResponse getMissionInfo(@RequestBody Map<String, Object> map) {
       return missionService.getMissionInfo(map);
    }

    @PostMapping("/editMission")
    public MsgResponse editMission(@RequestBody Map<String, Object> map) {
        return missionService.editMission(map);
    }

    @PostMapping("/close")
    public MsgResponse close(@RequestBody Map<String, Object> map) {
        return missionService.close(map);
    }


    @PostMapping("/getApplyPage")
    public MsgResponse getApplyPage(@RequestBody MissionDto missionDto){
        if(StrUtil.isEmpty(missionDto.getParam().getId())){
            return ResultUtils.fail("请检查参数");
        }
        return missionService.getApplyPage(missionDto);
    }
}
